package cn.edu.scau.cmi.dengzejun.chapter10;

import java.io.*;

public class Example7 {
	public static void main(String args[]) {
		RandomAccessFile inAndOut = null;
		int [] data = new int[10];
		for (int i = 1; i<=10 ;++i) {
			data[i] = i;
		}
		try {
			inAndOut = new RandomAccessFile("tom.dat","rw");
			for (int i = 0;i<data.length; ++i) {
				inAndOut.writeInt(data[i]);
			}
			for (long i = data.length-1;i>=0;--i) {
				inAndOut.seek(i*4);
				System.out.printf("\t%d", inAndOut.readInt());
			}
			inAndOut.close();
		}catch(IOException e) {
			System.out.println(e);
		}
		return;
	}
}
